﻿namespace System.Data.Entity.Utilities
{
    using System.Collections.Generic;
    using System.Data.Entity.Migrations.Model;
    using System.Reflection;

    public static class CreateTableOperationExtensions
    {
        public static TAnnotation GetTableAnnotation<TAnnotation>(this CreateTableOperation createTableOperation, string name)
            where TAnnotation : class
        {
            string annotationName = typeof(TAnnotation)
                .GetField("AnnotationName", BindingFlags.Static | BindingFlags.Public)
                .GetValue(null) as string;

            object annotation;

            createTableOperation.Annotations
                .TryGetValue(annotationName, out annotation);

            return annotation as TAnnotation;
        }

        public static IEnumerable<TAnnotation> GetColumnsAnnotations<TAnnotation>(this CreateTableOperation createTableOperation, string name)
        {
            throw new NotImplementedException();
        }
    }
}
